﻿using System.Collections.Generic;

using NUnit.Framework;
using NUnit.Framework.SyntaxHelpers;

using SharpArch.Core.PersistenceSupport;
using SharpArch.Testing.NUnit;

using Quiziqal.Domain;

namespace Quiziqal.Specifications.Domain
{
    [TestFixture]
    public class when_creating_a_user : BehaviorSpecificationTestsBase
    {
        User ragnar;
        User samba;
        const string RAGNARS_USERNAME = "Ragnar.Flengsrud";
        const string SAMBAS_USERNAME = "Sambasivarothy.Thiagalingam";

        protected override void EstablishContext() { }

        protected override void Act()
        {
            ragnar = new User(RAGNARS_USERNAME);
            samba = new User(SAMBAS_USERNAME);
        }

        [Test]
        public void username_should_be_set_via_constructor()
        {
            ragnar.Username.ShouldEqual(RAGNARS_USERNAME);
        }

        [Test]
        public void users_with_different_usernames_should_not_be_equal()
        {
            ragnar.ShouldNotEqual(samba);
        }
    }

    [TestFixture]
    public class when_creating_a_user_with_an_empty_username : BehaviorSpecificationTestsBase
    {
        User user1;
        User user2;

        protected override void EstablishContext() { }

        protected override void Act()
        {
            user1 = new User();
            user2 = new User(string.Empty);
        }

        [Test]
        public void should_not_be_valid()
        {
            user1.IsValid().ShouldBeFalse();
            user2.IsValid().ShouldBeFalse();
        }
    }
}
